Skip to content

Keep response status pending after zero-byte ReadFrom - #45

Closed
omrzk wants to merge 1 commit into
felixge:masterfrom
omrzk:fix/empty-readfrom-status-42
Closed

omrzk wants to merge 1 commit into
felixge:masterfrom
omrzk:fix/empty-readfrom-status-42

Conversation

@omrzk

@omrzk omrzk commented Oct 25, 2026

Copy link
Copy Markdown

Fixes #42.

An io.Copy that produces no bytes can leave net/http's status uncommitted. The ReadFrom hook currently marks the header written anyway, so a subsequent 502 or 204 is captured as 200.

Only mark the header written when ReadFrom reports positive progress. Add local HTTP server regressions for empty EOF and an immediate reader error, plus a nonempty-copy control. The tests compare both the client's response status and captured metrics; the two zero-byte cases fail on master.

make ci (including wrapper regeneration and race tests), go vet ./..., gofmt and git diff --check pass on Go 1.26.10. Generated wrappers are unchanged.

@omrzk

omrzk commented Oct 25, 2026

Copy link
Copy Markdown
Author

Closing as a duplicate of #44. I missed the closed PR during screening.

@omrzk omrzk closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CaptureMetrics reports 200 after a zero-byte ReadFrom

1 participant